package net.badcurrent.ldapodm;

import net.badcurrent.ldapodm.typeconverter.TypeConverter;

import javax.naming.directory.Attributes;
import java.util.Collection;

/**
 * <code>SessionImplementor</code> is the main interface of interaction to an LDAP-ORM
 * instance usable by internal components.
 *
 * @author John D'Emic <john.demic@gmail.com>
 */
public interface SessionImplementor {
    /**
     * Return a <code>Collection</code> of attribute names for the given Javabean
     * property.
     *
     * @param clazz
     * @param propertyName
     * @return a <code>Collection</code> of attribute names
     */
    Collection<String> getAttributesForProperty(Class clazz, String propertyName);

    /**
     * Return the registered <code>TypeConverter</code> for the given Class.
     *
     * @param clazz
     * @return the registered <code>TypeConverter</code>
     */
    TypeConverter getTypeConverter(Class clazz);

    /**
     * Update the <code>UnitOfWork</code> associated with the given object and
     * property with the supplied <code>Attributes</code>.
     *
     * @param o
     * @param propertyName
     * @param attrs
     */
    void updateUnitOfWork(Object o, String propertyName, Attributes attrs);

    /**
     * Determine if the supplied Javabean property name for the given Class
     * is registered as an LDAP properyt.
     *
     * @param clazz
     * @param propertyName
     * @return true if propertyName is registered, false if not
     */
    boolean isLdapProperty(Class clazz, String propertyName);

    /**
     * Determine if the supplied object is associated with the <code>Session</code>.
     *
     * @param o
     * @return true if the object is attached, false if not.
     */
    boolean isObjectAttached(Object o);


}
